//============================================================================
// Name        : threadsTutP.cpp
// Author      : alex2stf
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <stdio.h>
#include <pthread.h>

//using namespace std;
void * myFunc(void * myVar);

int main() {

pthread_t thread1, thread2;
char * msg1="fisrt thread";
char * msg2="second thread";
int ret1, ret2;

ret1=pthread_create(&thread1, NULL, myFunc, (void*) msg1);
ret2=pthread_create(&thread2, NULL, myFunc, (void*) msg2);


pthread_join(thread1, NULL);

pthread_join(thread2, NULL);

printf("thread ret1=%d", ret1);
printf("thread ret2=%d", ret2);

//	cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
	return 0;
}


void * myFunc(void * myVar){
	char *msg;
	msg=(char *) myVar;


	for(int i=0; i<10; i++){
		printf("%s %d \n", msg, i);
		sleep(1);
	}

	return NULL;
}
